package com.wangjiacai.utils.web.exception;



import com.wangjiacai.utils.enums.ResultEnum;
import com.wangjiacai.utils.web.translate.TranslateAnnotation;
import lombok.Data;
import lombok.Getter;

@Data
public class CodeMessageException extends RuntimeException{

    protected Integer code;

    @TranslateAnnotation
    protected String message;

    public CodeMessageException(ResultEnum resultEnum) {
        super(resultEnum.getMessage());
        this.message = resultEnum.getMessage();
        this.code = resultEnum.getCode();
    }

    public CodeMessageException(Integer code, String message) {
        super(message);
        this.message = message;
        this.code = code;
    }

    public CodeMessageException(String message) {
        super(message);
        this.message = ResultEnum.SERVER_ERROR.getMessage();
        this.code = ResultEnum.SERVER_ERROR.getCode();
    }
}
